﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace Etapa1.ComercioEspacial
{
    public partial class PDAForm : Form
    {
        PDA pda;
        public PDAForm(PDA 
            pda)
        {
            this.pda = pda;
            InitializeComponent();            
        }

        public void LoadAll()
        {

            dataGridView1.Columns.Clear();
            dataGridView2.Columns.Clear();

            dataGridView2.Rows.Clear();
            dataGridView2.Rows.Clear();            

            dataGridView1.Columns.Add("ProductName", "ProductName");
            dataGridView1.Columns.Add("Location", "Location");
            dataGridView1.Columns.Add("Distancia", "Distancia");
            dataGridView1.Columns.Add("Preco", "Preco");
            dataGridView1.Columns.Add("Quantidade", "Quantidade");


            dataGridView2.Columns.Add("ProductName", "ProductName");
            dataGridView2.Columns.Add("Location", "Location");
            dataGridView2.Columns.Add("Distancia", "Distancia");
            dataGridView2.Columns.Add("Preco", "Preco");
            dataGridView2.Columns.Add("Quantidade", "Quantidade");


            pda.CalculateProducts();

            foreach (var item in pda.prodDISPO)
	        {
                foreach (var item2 in item.Value)
	            {
            	    int n = dataGridView1.Rows.Add();
                    dataGridView1.Rows[n].Cells["ProductName"].Value = item.Key;
                    dataGridView1.Rows[n].Cells["Location"].Value = item2.owner;
                    dataGridView1.Rows[n].Cells["Distancia"].Value = 0;
                    dataGridView1.Rows[n].Cells["Preco"].Value = item2.preco;
                    dataGridView1.Rows[n].Cells["Quantidade"].Value = item2.quantidade;	 	 	                    
	            }        	    
	        }

            foreach (var item in pda.prodNECESS)
            {
                foreach (var item2 in item.Value)
                {
                    int n = dataGridView2.Rows.Add();
                    dataGridView2.Rows[n].Cells["ProductName"].Value = item.Key;
                    dataGridView2.Rows[n].Cells["Location"].Value = item2.owner;
                    dataGridView2.Rows[n].Cells["Distancia"].Value = 0;
                    dataGridView2.Rows[n].Cells["Preco"].Value = item2.preco;
                    dataGridView2.Rows[n].Cells["Quantidade"].Value = item2.quantidade;
                }
            }

            
	        

            


        }

        private void PDAForm_Load(object sender, EventArgs e)
        {
            LoadAll();
        }


    }
}
